all: common choosepoints

CXX = g++
objdir = build/obj/
bin = bin/
lib = bin/
dllext = dll

FLAGS = -lcv -lcxcore -lhighgui -I/usr/include/opencv/ -ICommon/ -IChoosePoints/ -L$(lib)

COMMON_OBJS = $(objdir)common/ImageDepthList.o $(objdir)common/PointsDatabase.o
CHOOSE_OBJS = $(objdir)choose/PointsUI.o

common: $(lib)libptscommon.$(dllext)
choosepoints: $(bin)choosepoints

$(bin)choosepoints: common $(CHOOSE_OBJS)
	@mkdir -p $(dir $@)
	@LIBRARY_PATH=$(lib)
	$(CXX) -o $(bin)choosepoints $(CHOOSE_OBJS) $(FLAGS) -lptscommon ChoosePoints/main.cpp

$(lib)libptscommon.$(dllext): $(COMMON_OBJS)
	@mkdir -p $(dir $@)
	$(CXX) -shared -o $(lib)libptscommon.$(dllext) $(COMMON_OBJS) $(FLAGS)

$(objdir)common/%.o: Common/%.cpp
	@mkdir -p $(dir $@)
	@echo "Compiling $<"
	$(CXX) $(FLAGS) \
		-c $< \
		-o $@
$(objdir)choose/%.o: ChoosePoints/%.cpp
	@mkdir -p $(dir $@)
	@echo "Compiling $<"
	$(CXX) $(FLAGS) \
		-c $< \
		-o $@

clean:
	rm -rf build bin lib
